/*
 * @Author: 1243sd 782012816@qq.com
 * @Date: 2024-03-13 20:48:19
 * @LastEditors: 1243sd 782012816@qq.com
 * @LastEditTime: 2024-06-26 23:17:10
 * @FilePath: \frontend-ykt-admin\src\mixinPageHeight.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export default {
  data() {
    return {}
  },
  activated() {
    if (this.$refs.bTable) {
      this.$refs.bTable.refresh();
    }
  },
  mounted() {
    this.setHeight()
  },
  updated() {
    this.setHeight()
  },
  methods: {
    setHeight() {
      this.$nextTick(() => {
        let bTableHeight = ''
        let bForm = this.$refs.bForm
        if (bForm) { // 有搜索条件
          if (bForm.$refs.searchText) { // 搜索条件超过一排
            if (this.tableHasOperation(this.$refs.bTable)) { // 判断表格有无tabs/handle操作
              bTableHeight = 'calc(100vh - 334px)' 
            } else {
              bTableHeight = 'calc(100vh - 286px)'
            }
          } else { // 搜索条件只有一排
            if (this.tableHasOperation(this.$refs.bTable)) { // 判断表格有无tabs/handle操作
              bTableHeight = 'calc(100vh - 312px)'
            } else {
              bTableHeight = 'calc(100vh - 264px)'
            }
          }
        } else { // 无搜索条件
          if (this.tableHasOperation(this.$refs.bTable)) { // 判断表格有无tabs/handle操作
            bTableHeight = 'calc(100vh - 240px)'
          } else {
            bTableHeight = 'calc(100vh - 192px)'
          }
        }
        this.dataForm.height = bTableHeight
      });
    },
    // 查询表格头上面有没有操作
    tableHasOperation(table) {
      // console.log(table.$refs);
      if (table && table.$refs && (table.$refs.tabsList || table.$refs.handleList)) {
        return true
      } else {
        return false
      }
    },
    // 点击搜索
    handleSearch(params) {
      this.dataForm.query = params;
      this.$refs.bTable.reload();
    },
    /// 刷新页面
    handleRefresh() {
      this.dataForm.query = this.$options.data().dataForm.query;
      this.$refs.bTable.reload();
    },
  }
}